﻿using DotNetNinjaLibrary.Basics;

namespace DotNetNinjaLibrary.Utils
{
	public static class IntersectionHelper
	{
		public static bool IntersectsWith(Point location1, Size size1, Point location2, Size size2)
		{
			return IntersectsWith(location1.X, location1.X + size1.Width, location2.X, location2.X + size2.Width) &&
				IntersectsWith(location1.Y, location1.Y + size1.Height, location2.Y, location2.Y + size2.Height);
		}

		public static bool IntersectsWith(int start1, int end1, int start2, int end2)
		{
			return start1 < end2 && start1 >= start2 || end1 <= end2 && end1 > start2 || start2 >= start1 && start2 < end1;
		}
	}
}
